﻿using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using DevManager.ViewModels.Pages;

namespace DevManager.Pages;

public partial class PageHeaderControl : UserControl
{
    public PageHeaderControl()
    {
        InitializeComponent();
    }

    protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
    {
        base.OnAttachedToVisualTree(e);
        
        Block.Text = (Parent?.DataContext as PageModelBase)?.PageName();
        
        Border.Background = new ImageBrush()
        {
            Source = new Bitmap(
                AssetLoader.Open(
                    new Uri($"avares://DevManager/Assets/Images/HeaderBackground{ActualThemeVariant.Key}.png"))),
            AlignmentY = AlignmentY.Center,
            Stretch = Stretch.UniformToFill
        };

        // Image.Source = 
    }
}